<?php
class Bank_manager extends Controller
{
    function __construct()
    {
        parent::__construct();
        
        $this->load->library('session');
	    if($this->session->userdata('admin') == '')
    	{
    		 redirect('admin');
    	}
        
		$this->load->helper(array('form','url'));
    }
    
    function index()
    {
      $this->load->library(array('form_validation'));
      
      $this->load->model('admin_bank_manager_model');
		
		if($_POST['submit'] == 'Submit')
		{
			$this->form_validation->set_error_delimiters('<div class="error">','</div>');
			
            $this->form_validation->set_rules('bank_accountholdername','bank account holder\'s name','required|trim|xss_clean');
            $this->form_validation->set_rules('bank_name','bank name','required|trim|xss_clean');			
			$this->form_validation->set_rules('account_number','account number','required|trim|xss_clean');			
			$this->form_validation->set_rules('branch','branch','required|trim|xss_clean');			
			$this->form_validation->set_rules('branch_code','branch code','required|trim|xss_clean');			
			$this->form_validation->set_rules('swift_code','international swift code','required|trim|xss_clean');
			
			//$this->validation->set_fields($fields);
			
			$this->form_validation->set_message('required', 'Please enter %s');
			
			
			if ($this->form_validation->run() == TRUE)
			{
 				$arr = array(
                                  'bank_accountholdername' => $this->input->post('bank_accountholdername'),
                                  'bank_manager_name' => $this->input->post('bank_name'),
                                  'bank_manager_account_number' => $this->input->post('account_number'),
                                  'bank_manager_branch' => $this->input->post('branch'),
                                  'bank_manager_branch_code' => $this->input->post('branch_code'),
                                  'bank_manager_swift_code' => $this->input->post('swift_code')
                            );
                $this->admin_bank_manager_model->updatedetails($arr);
                
				                
			}
				
		}
		
		      
        $data['query'] = $this->admin_bank_manager_model->getAllResult();
        
		$this->load->view(TEMPLATE_NAME.'/admin/admin_bank_manager_view', $data);	
        
        
    }
}
?>